/**
 * 
 */
package base.jmx.notification;

import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

import base.jmx.Hello;

import com.sun.jdmk.comm.HtmlAdaptorServer;

/**
 * @author bliu
 *
 */
public class HelloAgent {

	/**
	 * @param args
	 * @throws NullPointerException 
	 * @throws MalformedObjectNameException 
	 */
	public static void main(String[] args) throws Exception {
		        MBeanServer server = MBeanServerFactory.createMBeanServer();       
		        ObjectName helloName = new ObjectName("boen:name=HelloWorld");    
		        Hello hello=new Hello();          
		        server.registerMBean(hello, helloName);       
		        ObjectName adapterName = new ObjectName("HelloAgent:name=htmladapter,port=8082");      
		        HtmlAdaptorServer adapter = new HtmlAdaptorServer();       
		        server.registerMBean(adapter, adapterName);      
		        
		        Jack jack = new Jack();    //重点   
		        server.registerMBean(jack, new ObjectName("boen:name=jack"));    //重点   
		        jack.addNotificationListener(new HelloListener(), null, hello);    //重点   
		        adapter.start();           
		        System.out.println("start.....");     

	}

}
